<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Space - learning notes</title><meta name="keywords" content="笔记 学习"><meta name="author" content="Heldwen"><meta name="copyright" content="Heldwen"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="description" content="Good Good Study, Day Day Up!">
<meta property="og:type" content="website">
<meta property="og:title" content="Space">
<meta property="og:url" content="https://gitee.com/drh-space/myblog/index.html">
<meta property="og:site_name" content="Space">
<meta property="og:description" content="Good Good Study, Day Day Up!">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/drh-space/myblog/img/avatar.png">
<meta property="article:author" content="Heldwen">
<meta property="article:tag" content="笔记 学习">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/drh-space/myblog/img/avatar.png"><link rel="shortcut icon" href="/myblog/img/favicon.png"><link rel="canonical" href="https://gitee.com/drh-space/myblog/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="yandex-verification" content="{&quot;theme_color&quot;:{&quot;enable&quot;:true,&quot;main&quot;:&quot;#49B1F5&quot;,&quot;paginator&quot;:&quot;#00c4b6&quot;,&quot;button_hover&quot;:&quot;#FF7242&quot;,&quot;text_selection&quot;:&quot;#00c4b6&quot;,&quot;link_color&quot;:&quot;#99a9bf&quot;,&quot;meta_color&quot;:&quot;#858585&quot;,&quot;hr_color&quot;:&quot;#A4D8FA&quot;,&quot;code_foreground&quot;:&quot;#F47466&quot;,&quot;code_background&quot;:&quot;rgba(27, 31, 35, .05)&quot;,&quot;toc_color&quot;:&quot;#00c4b6&quot;,&quot;blockquote_padding_color&quot;:&quot;#49b1f5&quot;,&quot;blockquote_background_color&quot;:&quot;#49b1f5&quot;}}"/><link rel="stylesheet" href="/myblog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css"><script>var GLOBAL_CONFIG = { 
  root: '/myblog/',
  hexoversion: '5.2.0',
  algolia: undefined,
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  ClickShowText: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"bottom-left"},
  justifiedGallery: {
    js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
    css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isanchor: false
};

var saveToLocal = {
  set: function setWithExpiry(key, value, ttl) {
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: false,
  isHome: true,
  isHighlightShrink: false,
  isSidebar: false,
  postUpdate: '03-22-2022 12:47:38'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {
  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }

  const autoChangeMode = 'true'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified

    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }
})()</script><meta name="generator" content="Hexo 5.2.0"><link rel="alternate" href="/myblog/atom.xml" title="Space" type="application/atom+xml">
</head><body><div id="mobile-sidebar"><div id="menu_mask"></div><div id="mobile-sidebar-menus"><div class="mobile_author_icon"><img class="avatar-img" data-lazy-src="/myblog/img/avatar.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="mobile_post_data"><div class="mobile_data_item is-center"><div class="mobile_data_link"><a href="/myblog/archives/"><div class="headline">文章</div><div class="length_num">7</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/myblog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/myblog/%E5%8A%A8%E6%80%81/"><i class="fa-fw fas fa-archive"></i><span> 动态</span></a></div><div class="menus_item"><a class="site-page" href="/myblog/%E6%A0%87%E7%AD%BE/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/myblog/%E5%88%86%E7%B1%BB/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/myblog/%E9%9F%B3%E4%B9%90/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page" href="/myblog/%E7%94%B5%E5%BD%B1/"><i class="fa-fw fas fa-movies"></i><span> 电影</span></a></li><li><a class="site-page" href="/myblog/%E6%97%85%E8%A1%8C/"><i class="fa-fw fas fa-travel"></i><span> 旅行</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/myblog/%E5%85%B3%E4%BA%8E/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div id="body-wrap"><div id="web_bg"></div><header class="full_page" id="page-header" style="background-image: url(/myblog/img/cover3.jpg)"><nav id="nav"><span id="blog_name"><a id="site-name" href="/myblog/">Space</a></span><span id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/myblog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/myblog/%E5%8A%A8%E6%80%81/"><i class="fa-fw fas fa-archive"></i><span> 动态</span></a></div><div class="menus_item"><a class="site-page" href="/myblog/%E6%A0%87%E7%AD%BE/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/myblog/%E5%88%86%E7%B1%BB/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/myblog/%E9%9F%B3%E4%B9%90/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page" href="/myblog/%E7%94%B5%E5%BD%B1/"><i class="fa-fw fas fa-movies"></i><span> 电影</span></a></li><li><a class="site-page" href="/myblog/%E6%97%85%E8%A1%8C/"><i class="fa-fw fas fa-travel"></i><span> 旅行</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/myblog/%E5%85%B3%E4%BA%8E/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><span class="close" id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></span></span></nav><div id="site-info"><h1 id="site-title">Space</h1><div id="site-subtitle"><span id="subtitle"></span></div><div id="site_social_icons"><a class="social-icon" href="https://github.com/drh-space" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="https://gitee.com/drh-space" target="_blank" title="Gitee"><i class="fab fa-google"></i></a><a class="social-icon" href="https://blog.csdn.net/m0_46100784?type=blog" target="_blank" title="CSDN"><i class="fas fa-link"></i></a></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout_page" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="post_cover left_radius"><a href="/myblog/03/22/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B06%EF%BC%9ASpring%E5%85%A5%E9%97%A8/" title="javaEE(SSM)学习笔记6：Spring入门">     <img class="post_bg" data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记6：Spring入门"></a></div><div class="recent-post-info"><a class="article-title" href="/myblog/03/22/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B06%EF%BC%9ASpring%E5%85%A5%E9%97%A8/" title="javaEE(SSM)学习笔记6：Spring入门">javaEE(SSM)学习笔记6：Spring入门</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-03-21T17:13:56.798Z" title="发表于 03-22-2022 01:13:56">03-22-2022</time><span class="article-meta__separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-03-22T04:46:55.240Z" title="更新于 03-22-2022 12:46:55">03-22-2022</time></span></div><div class="content">1 Spring概述1.1 什么是Spring一个Java 应用程序开发框架，为Java EE三层(架构)开发模式的各层都提供解决方案。

三层架构：通常意义上的三层架构就是将整个业务应用划分为以下三层：
表现层（UI）、业务逻辑层（BLL）、数据访问层（DAL）。
区分层次的目的使得每一层都有明确的职责；每一层的修改对其他层影响较小。

Spring对三层的支持：

（1）表现层：提供springMVC
（2）业务层（业务逻辑层）：提供了事务管理、安全、日志记录等功能
（3）持久层（数据访问层）：提供JdbcTemplate技术简化数据库开发，或提供与其他框架整合的接口，如mybatis(开发平台)

1.2  核心功能
（主要掌握）控制反转Ioc和依赖注入DI，以及面向切面的编程AOP

1.3 优点（主要是指其核心功能特征）
（1）非侵入式设计： Spring是一种非侵入式（non-invasive）框架，所谓的非侵入式是指允许应用程序中自由选择和组装Spring框架的各个功能模块，并且不要求应用程序的类必须继承或者实现Spring框架的某个类或某法接口。由于业务逻辑中没有Spr ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/myblog/03/17/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B05%EF%BC%9A%E5%85%B3%E8%81%94%E6%98%A0%E5%B0%84/" title="javaEE(SSM)学习笔记5：关联映射">     <img class="post_bg" data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记5：关联映射"></a></div><div class="recent-post-info"><a class="article-title" href="/myblog/03/17/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B05%EF%BC%9A%E5%85%B3%E8%81%94%E6%98%A0%E5%B0%84/" title="javaEE(SSM)学习笔记5：关联映射">javaEE(SSM)学习笔记5：关联映射</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-03-17T10:09:04.855Z" title="发表于 03-17-2022 18:09:04">03-17-2022</time><span class="article-meta__separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-03-17T10:10:55.340Z" title="更新于 03-17-2022 18:10:55">03-17-2022</time></span></div><div class="content">[概念]关联映射： 从多个关联表查询所需要的数据。

（1）关联，是指表与表之间的联系；关联关系有：1:1 ；1:n ；n:n 。
（2）映射是指将关联表之间的查询结果，自动进行类型转换和并存到java对象的各个对应的属性中。也就是表字段值映射到对象的属性值；
（3）关联映射通常是指关联表的查询操作，将查询结果保存到对象的基础属性及复合属性中。

通常一个表会对应定义一个java对象（pojo）来保存数据，当相关的其他表的数据，也要保存在这个对象中时，可以在该对象中定义一个包含其他对象的属性（这里称之为：复合属性/关联属性）。
例如：当查询用户时，将其对应的身份证信息（其他表）同时查询出来并保存，可以定义两个java对象：User和IDCard ，对应两表的数据；查询出User信息后，根据关联关系，再查询出IDCard信息，将IDCard的查询结果，作为User的一个属性，进行保存。
如果此时在User对象中也定义IDCard的每一个属性，那么这是冗余且不规范的、不合理的。
[概念]关联表的查询： 分为嵌套查询（可懒加载）和嵌套结果（常用）。

（1）嵌套查询：先根据条件在一个表中查询 ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/myblog/03/11/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B04%EF%BC%9A%E5%8A%A8%E6%80%81SQL/" title="javaEE(SSM)学习笔记4：动态SQL">     <img class="post_bg" data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记4：动态SQL"></a></div><div class="recent-post-info"><a class="article-title" href="/myblog/03/11/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B04%EF%BC%9A%E5%8A%A8%E6%80%81SQL/" title="javaEE(SSM)学习笔记4：动态SQL">javaEE(SSM)学习笔记4：动态SQL</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-03-10T16:26:57.249Z" title="发表于 03-11-2022 00:26:57">03-11-2022</time><span class="article-meta__separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-03-10T16:36:39.378Z" title="更新于 03-11-2022 00:36:39">03-11-2022</time></span></div><div class="content">动态SQL引入 
【主要作用】：根据不同条件，或者不同数据，拼接SQL子句，在XML文件中实现类似编程的效果。
【主要元素（标记）】：

查询条件：单分支  if；多分支choose… when… other
特殊处理：where /trim
更新数据：set
复杂查询与更新：foreach

条件查询操作1. &lt;if&gt;元素根据条件拼接SQL语句，满足条件即包含SQL子句。
（1）语法
123&lt;if test=&quot;条件表达式&quot;&gt;    SQL子句&lt;/if&gt;


1.条件表达式：基本都是比较运算或者逻辑运算，结果为true或false
2.运算符： 大于；大于等于；等于；不等于；小于；小于等于，由于 &lt;和&gt;为XML的特殊字符，不能直接使用，因此mybatis使用以下对应的运算符：
比较运算符：gt  、  gte 、   ==  、 != 、 lt  、 lte ；
逻辑运算符：使用 and 和  or 代替 &amp;&amp; 和  || 

（2）示例1：模糊匹配
【需求】根据输入的姓名或职业模糊查询客户表中的客户信 ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/myblog/03/04/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B03%EF%BC%9AMybatis%E6%A0%B8%E5%BF%83%E5%AF%B9%E8%B1%A1%E5%8F%8A%E5%85%B6%E9%85%8D%E7%BD%AE/" title="javaEE(SSM)学习笔记3：Mybatis核心对象及其配置">     <img class="post_bg" data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记3：Mybatis核心对象及其配置"></a></div><div class="recent-post-info"><a class="article-title" href="/myblog/03/04/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B03%EF%BC%9AMybatis%E6%A0%B8%E5%BF%83%E5%AF%B9%E8%B1%A1%E5%8F%8A%E5%85%B6%E9%85%8D%E7%BD%AE/" title="javaEE(SSM)学习笔记3：Mybatis核心对象及其配置">javaEE(SSM)学习笔记3：Mybatis核心对象及其配置</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-03-04T15:23:48.016Z" title="发表于 03-04-2022 23:23:48">03-04-2022</time><span class="article-meta__separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-03-10T04:49:49.918Z" title="更新于 03-10-2022 12:49:49">03-10-2022</time></span></div><div class="content">总体思路：
SqlSession是实际执行SQL的接口，其从Mybatis的核心对象SqlSessionFactory接口的方法openSession获取；而SqlSessionFactory接口的实现类由SqlSessionFactoryBuilder对象创建。

1.核心对象(了解)
SqlSessionFactory接口对象是Mybatis的核心对象，由SqlSessionFactoryBuilder的方法创建。

1.1 SqlSessionFactoryBuilder（1）主要作用
使用build方法，读取并解析Mybatis的XML配置文件，将解析结果保存到配置对象，并创建和返回SqlSessionFactory实现类（DefaultSqlSessionFactory）

1.解析属性，或读取属性文件(properties);
2.映射POJO类的别名;(typeAliases)
3.读取mybatis的全局配置(settings)
4.构建数据源和事务管理器(environments)等。
5.装载mapper文件，将不同命名空间的mapper文件中的id对应sql语句分 ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/myblog/03/03/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B02%EF%BC%9AMybatis%E5%85%A5%E9%97%A8/" title="javaEE(SSM)学习笔记2：Mybatis入门">     <img class="post_bg" data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记2：Mybatis入门"></a></div><div class="recent-post-info"><a class="article-title" href="/myblog/03/03/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B02%EF%BC%9AMybatis%E5%85%A5%E9%97%A8/" title="javaEE(SSM)学习笔记2：Mybatis入门">javaEE(SSM)学习笔记2：Mybatis入门</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-03-03T07:04:16.610Z" title="发表于 03-03-2022 15:04:16">03-03-2022</time><span class="article-meta__separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-03-10T04:45:32.279Z" title="更新于 03-10-2022 12:45:32">03-10-2022</time></span></div><div class="content">Mybatis简介

一个封装了JDBC对数据库操作的框架，也是一个ORM（对象关系映射）框架。

最主要特点

简化对数据库的操作，并能够将查询结果自动映射到Java的对象POJO(Persistent Object  Java Object /Plain(简单) Ordinary(普通的) Java Object   ，就是简单的java实体类)

1.理解使用mybatis框架的好处1.1使用jsp实现对数据库的查询的典型示例(对比效果)12345拼接url链接字符串,作为参数获取连接对象拼接SQL语句，作为参数，创建语句对象Statement&#x2F;PreparedStatement执行SQL，获取结果集对象从结果集中获取不同类型数据，进行转换数据类型在保存关闭对象


1.手动创建数据库连接对象，最后手动关闭数据库对象2.手动给SQL参数赋值；3.查询结果需要手动设置到对象的属性最关键的是：每个servlet中都需要重复的操作—代码冗余

如JSP添加数据和查询数据：
123456789101112131415161718192021222324252627282930	 ...</div></div></div><div class="recent-post-item"><div class="post_cover right_radius"><a href="/myblog/02/28/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B01%EF%BC%9A%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/" title="javaEE(SSM)学习笔记1：环境配置">     <img class="post_bg" data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记1：环境配置"></a></div><div class="recent-post-info"><a class="article-title" href="/myblog/02/28/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B01%EF%BC%9A%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/" title="javaEE(SSM)学习笔记1：环境配置">javaEE(SSM)学习笔记1：环境配置</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-02-28T14:00:25.575Z" title="发表于 02-28-2022 22:00:25">02-28-2022</time><span class="article-meta__separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-03-10T04:45:11.604Z" title="更新于 03-10-2022 12:45:11">03-10-2022</time></span></div><div class="content">
按步骤实现，否则可能出现一些问题

1.下载maven管理工具https://maven.apache.org/download.cgi    选择下载：    apache-maven-3.8.4-bin.zip
解压后放在 D:\apache-maven-3.8.4，下面的操作默认这个位置


2.设置环境变量我的电脑==右键==属性
 用于全局执行bin下面的mvn命令（应用程序）


3.打开配置文件进行修改文件目的：使用maven的阿里云镜像，更快的下载，并保存到自己的本地仓库中。
 文件位置：D:\apache-maven-3.8.4\conf\settings.xml
(1)指定本地仓库
 找到在settings 标记：添加  localRepository标记  和如下内容； 这是在D盘自己创建的myrepository 文件夹：这里将保存的所有下载的jar包的位置
1234567&lt;!-- localRepository | The path to the local repository maven will use to store artifacts. | ...</div></div></div><div class="recent-post-item"><div class="post_cover left_radius"><a href="/myblog/02/26/2022/Hello-World/" title="Hello World!">     <img class="post_bg" data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="Hello World!"></a></div><div class="recent-post-info"><a class="article-title" href="/myblog/02/26/2022/Hello-World/" title="Hello World!">Hello World!</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-02-26T09:03:39.000Z" title="发表于 02-26-2022 17:03:39">02-26-2022</time><span class="article-meta__separator">|</span><i class="fas fa-history"></i><span class="article-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-02-26T09:03:39.080Z" title="更新于 02-26-2022 17:03:39">02-26-2022</time></span></div><div class="content"></div></div></div><nav id="pagination"><div class="pagination"><span class="page-number current">1</span></div></nav></div><div class="aside_content" id="aside_content"><div class="card-widget card-info"><div class="card-content"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="/myblog/img/avatar.png" onerror="this.onerror=null;this.src='/myblog/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">Heldwen</div><div class="author-info__description">Good Good Study, Day Day Up!</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/myblog/archives/"><div class="headline">文章</div><div class="length_num">7</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/drh-space"><i class="fab fa-github"></i><span>My Github</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/drh-space" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="https://gitee.com/drh-space" target="_blank" title="Gitee"><i class="fab fa-google"></i></a><a class="social-icon" href="https://blog.csdn.net/m0_46100784?type=blog" target="_blank" title="CSDN"><i class="fas fa-link"></i></a></div></div></div><div class="sticky_layout"><div class="card-widget card-announcement"><div class="card-content"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is my space.</div></div></div><div class="card-widget card-recent-post"><div class="card-content"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/myblog/03/22/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B06%EF%BC%9ASpring%E5%85%A5%E9%97%A8/" title="javaEE(SSM)学习笔记6：Spring入门"><img data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记6：Spring入门"/></a><div class="content"><a class="title" href="/myblog/03/22/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B06%EF%BC%9ASpring%E5%85%A5%E9%97%A8/" title="javaEE(SSM)学习笔记6：Spring入门">javaEE(SSM)学习笔记6：Spring入门</a><time datetime="2022-03-21T17:13:56.798Z" title="发表于 03-22-2022 01:13:56">03-22-2022</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/myblog/03/17/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B05%EF%BC%9A%E5%85%B3%E8%81%94%E6%98%A0%E5%B0%84/" title="javaEE(SSM)学习笔记5：关联映射"><img data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记5：关联映射"/></a><div class="content"><a class="title" href="/myblog/03/17/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B05%EF%BC%9A%E5%85%B3%E8%81%94%E6%98%A0%E5%B0%84/" title="javaEE(SSM)学习笔记5：关联映射">javaEE(SSM)学习笔记5：关联映射</a><time datetime="2022-03-17T10:09:04.855Z" title="发表于 03-17-2022 18:09:04">03-17-2022</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/myblog/03/11/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B04%EF%BC%9A%E5%8A%A8%E6%80%81SQL/" title="javaEE(SSM)学习笔记4：动态SQL"><img data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记4：动态SQL"/></a><div class="content"><a class="title" href="/myblog/03/11/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B04%EF%BC%9A%E5%8A%A8%E6%80%81SQL/" title="javaEE(SSM)学习笔记4：动态SQL">javaEE(SSM)学习笔记4：动态SQL</a><time datetime="2022-03-10T16:26:57.249Z" title="发表于 03-11-2022 00:26:57">03-11-2022</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/myblog/03/04/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B03%EF%BC%9AMybatis%E6%A0%B8%E5%BF%83%E5%AF%B9%E8%B1%A1%E5%8F%8A%E5%85%B6%E9%85%8D%E7%BD%AE/" title="javaEE(SSM)学习笔记3：Mybatis核心对象及其配置"><img data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记3：Mybatis核心对象及其配置"/></a><div class="content"><a class="title" href="/myblog/03/04/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B03%EF%BC%9AMybatis%E6%A0%B8%E5%BF%83%E5%AF%B9%E8%B1%A1%E5%8F%8A%E5%85%B6%E9%85%8D%E7%BD%AE/" title="javaEE(SSM)学习笔记3：Mybatis核心对象及其配置">javaEE(SSM)学习笔记3：Mybatis核心对象及其配置</a><time datetime="2022-03-04T15:23:48.016Z" title="发表于 03-04-2022 23:23:48">03-04-2022</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/myblog/03/03/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B02%EF%BC%9AMybatis%E5%85%A5%E9%97%A8/" title="javaEE(SSM)学习笔记2：Mybatis入门"><img data-lazy-src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/myblog/img/404.jpg'" alt="javaEE(SSM)学习笔记2：Mybatis入门"/></a><div class="content"><a class="title" href="/myblog/03/03/2022/javaEE(SSM)%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B02%EF%BC%9AMybatis%E5%85%A5%E9%97%A8/" title="javaEE(SSM)学习笔记2：Mybatis入门">javaEE(SSM)学习笔记2：Mybatis入门</a><time datetime="2022-03-03T07:04:16.610Z" title="发表于 03-03-2022 15:04:16">03-03-2022</time></div></div></div></div></div><div class="card-widget card-archives"><div class="card-content"><div class="item-headline"><i class="fas fa-archive"></i><span>归档</span></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/myblog/archives/2022/03/"><span class="card-archive-list-date">三月 2022</span><span class="card-archive-list-count">5</span></a></li><li class="card-archive-list-item"><a class="card-archive-list-link" href="/myblog/archives/2022/02/"><span class="card-archive-list-date">二月 2022</span><span class="card-archive-list-count">2</span></a></li></ul></div></div><div class="card-widget card-webinfo"><div class="card-content"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">7</div></div><div class="webinfo-item"><div class="item-name">已运行时间 :</div><div class="item-count" id="runtimeshow" data-publishDate="2022-03-22T04:47:38.093Z"></div></div><div class="webinfo-item"><div class="item-name">本站访客数 :</div><div class="item-count" id="busuanzi_value_site_uv"></div></div><div class="webinfo-item"><div class="item-name">本站总访问量 :</div><div class="item-count" id="busuanzi_value_site_pv"></div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2022-03-22T04:47:38.093Z"></div></div></div></div></div></div></div></main><footer id="footer" style="background-image: url(/myblog/img/cover3.jpg)"><div id="footer-wrap"><div class="copyright">&copy;2022 By Heldwen</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Welcome To My Space !</div></div></footer></div><section id="rightside"><div id="rightside-config-hide"><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></section><div><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="/myblog/js/utils.js"></script><script src="/myblog/js/main.js"></script><script src="/myblog/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module" defer></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.spacingElementById('content-inner')
  else {
    $.getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js', () => {
      pangu.spacingElementById('content-inner')
    })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguFn)</script><div class="js-pjax"><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    $.getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js', function () {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      false && mermaid.init()
    })
  }
}</script><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><canvas class="fireworks" mobile="true"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="true" data-click="true"></script><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = true;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="true"></script></div></body></html>